package org.example.demo.test.search.strategy.reveal.defau;

import com.example.demo.test.AbstractStrategyRouter;
import com.example.demo.test.StrategyHandler;
import com.example.demo.test.parm.InClass;
import com.example.demo.test.parm.OutClass;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 默认策略
 */
@Component
@Slf4j
public class DefaultStrategy  extends AbstractStrategyRouter<InClass, OutClass> implements StrategyHandler<InClass,OutClass> {
    @Override
    protected StrategyMapper<InClass, OutClass> registerStrategyMapper() {
        return new StrategyMapper<InClass, OutClass>() {
            @Override
            public StrategyHandler<InClass, OutClass> get(InClass entity) {
                //TODO 其他的限制条件
                if(entity.getNumFound()>1000 && entity.getNumFound()<=10000){
                    return new CutTime();
                }else if(entity.getNumFound()>10000){
                    return new CutTimeAndArea();
                }else if (entity.getNumFound() <= 20){
                    return new ExpandTime();
                }
                return null;
            }
        };
    }

    @Override
    public OutClass apply(InClass param) {
        // TODO 不做任何操作
        return applyStrategy(param);
    }
}
